package com.base.leetcode;

import com.base.dataStructure.Tree.TreeNode;

/**
 * @Author: hdhao
 * @Create: 2023/4/5 - 20:10
 * @Version: v1.0
 */
//翻转二叉树
public class Leetcode226 {
    public TreeNode invertTree(TreeNode root) {
        fn(root);
        return root;
    }

    private static void fn(TreeNode node) {
        if (node == null) {
            return;
        }
        TreeNode tmp = node.left;
        node.left = node.right;
        node.right = tmp;
        fn(node.left);
        fn(node.right);
    }
}
